﻿using System;

namespace ExFlash.Tags
{
    public class DefineVideoStreamTag : Tag, IHasCharacterId
    {
        public ushort CharacterId
        {
            get;
            protected set;
        }

        public ushort NumFrames
        {
            get;
            protected set;
        }

        public ushort Width
        {
            get;
            protected set;
        }

        public ushort Height
        {
            get;
            protected set;
        }

        public DeblockingFilters VideoFlagsDeblocking
        {
            get;
            protected set;
        }

        public Boolean VideoFlagsSmoothing
        {
            get;
            protected set;
        }

        public Codecs CodecId
        {
            get;
            protected set;
        }

        public DefineVideoStreamTag(int len, int offset)
            : base(TagCodes.DefineVideoStream, len, offset)
        {

        }
        public override void SwfDeserialize(BinaryBitReader reader)
        {
            CharacterId = reader.ReadUInt16();

            NumFrames = reader.ReadUInt16();

            Width = reader.ReadUInt16();

            Height = reader.ReadUInt16();

            reader.SkipBits(4);
            VideoFlagsDeblocking = (DeblockingFilters)reader.ReadUInt32(3);
            VideoFlagsSmoothing = reader.ReadBoolean();

            reader.AlignBits();

            CodecId = (Codecs)reader.ReadByte();
        }

        public override void SwfSerialize(byte[] arr, ref int offset)
        {
            throw new NotImplementedException();
        }

        #region IHasCharacterID Members

        public ushort Id
        {
            get { return CharacterId; }
        }

        #endregion
    }
}
